package controllers

import (
	"database/sql"
	"net/http"

	"github.com/gin-gonic/gin"
	"web-service/models"
)

type StatsController struct {
	DB *sql.DB
}

// GetStats 获取统计数据
func (sc *StatsController) GetStats(c *gin.Context) {
	stats, err := models.GetStats(sc.DB)
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"code": 500, "message": "获取统计数据失败"})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"data": stats,
	})
}
